<form class="layui-form ptb15 pr20 js-view-addMenus" method="post" action="{:U('Site/addMenus')}?id={$row.id??''}" >
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" value="{$row.title??''}" lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input w200" maxlength="50" autofocus/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">英文别名</label>
        <div class="layui-input-block">
            <input type="text" name="en_title" value="{$row.en_title??''}" placeholder="请输入英文别名" autocomplete="off" class="layui-input w200" maxlength="50"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">目录名称</label>
        <div class="layui-input-block">
            <input type="text" name="dir_name" value="{$row.dir_name??''}" autocomplete="off" class="layui-input w200" maxlength="50" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9_]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\[^a-zA-Z0-9_]/g,''));"/>
            <p class="f12 cl-999">用于伪静态，留空系统默认全拼音+随机数<br/>仅支持字母、数字、下划线</p>
        </div>
    </div>
    {if isset($pid)&&$pid&&$ptitle }
    <div class="layui-form-item">
        <label class="layui-form-label">上级菜单</label>
        <div class="layui-input-block"><input value="{$ptitle}" class="layui-input" disabled style="border: none;"/>
            <input type="hidden" name="parent_id" value="{$pid}"/>
        </div>
    </div>
    {/if}
    <div class="layui-form-item">
        <label class="layui-form-label">新窗口打开</label>
        <div class="layui-input-block">
            <input type="radio" name="target_blank" value="true" title="是" {if isset($row['target_blank'])&&$row['target_blank']=='true' }checked{/if}/>
            <input type="radio" name="target_blank" value="false" title="否" {if !isset($row['target_blank'])||$row['target_blank']!='true' }checked{/if}/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">页面链接</label>
        <div class="layui-input-block">
            <input type="text" name="url" value="{$row.url??''}" autocomplete="off" class="layui-input w200" maxlength="100"/>
            <div class="mt10">
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/">首页</a>
            </div>
            <div class="mt10">
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/article/%id.html" href="{:U('Article/index')}">文章页</a>
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/node/%id.html" href="{:U('Article/nodes')}">文章栏目</a>
            </div>
            <div class="mt10">
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/item/%id.html" href="{:U('Goods/index')}">产品页</a>
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/cat/%id.html" href="{:U('Goods/cat')}">产品分类</a>
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/cats.html">全部产品</a>
                <a class="js-link layui-btn layui-btn-primary layui-btn-xs" data-link="/brand.html">品牌页</a>
            </div>
        </div>
    </div>
    <div class="layui-form-item text-center mt30">
        <button type="submit" class="layui-btn layui-btn-normal w100" lay-submit>保存</button>
    </div>
</form>
<script>
    (function () {
        var $view = $('.js-view-addMenus');
        $('a.js-link', $view).on('click',function () {
            var $this = $(this), link = $this.data('link'),
                href = $this.attr('href');
            if (!href) {
                link && $this.parent().siblings('input').val(link);
                return false;
            }
            $.dialog({
                title: false,
                url: href,
                data: { checkType: 'radio', },
                area: ['1024px', '550px'],
                yes: function (layero, index) {
                    var $tr = $('tr.selected', layero);
                    if (!$tr.length) {
                        $.showMsg(false, '请选择数据行！');
                        return false;
                    }
                    var id = $tr.data('id');
                    link = link.replace('%id', id);
                    $this.parent().siblings('input').val(link);
                }
            });
            return false;
        });
    })();
</script>